﻿@using MC.RideEvent.Mvc.Helpers
@using MC.RideEvent.Mvc.Models.ViewModel
@model DetailEventViewModel

@{
    ViewBag.Title = "Detail";
    var member = Session["CurrentMember"] as MemberViewModel;
}

<h2>Detail</h2>

<fieldset>
    <legend>Event</legend>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.Title)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Event.Title)
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.NamePlace)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Event.NamePlace)
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.Description)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Event.Description)
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.Price)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Event.Price)
    </div>

    <div class="display-label">
        @Html.DisplayName("Adresse complete")
    </div>
    <div class="display-field">
        @Html.Label(Model.Event.FullAddress())
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.DateBegin)
    </div>
    <div class="display-field">
        @Html.Label("", Model.Event.DateBegin.ToStringFr())
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.DateEnd)
    </div>
    <div class="display-field">
        @Html.Label("", Model.Event.DateEnd.ToStringFr())
    </div>

    <div class="display-label">
        @Html.DisplayNameFor(model => model.Event.SiteLink)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Event.SiteLink)
    </div>

</fieldset>
@if(member != null)
{
    <div class="zoneAction">
        @*@Html.ActionLink("Devenir passager", "ListWaysForPassager", "Way", new {@eventId = Model.Event.Id}, new {@class = "linkAction"})*@

        @if(member.Vehicules.Count > 0)
        {
            var list = Model.Ways.Select(w => w.Id).Intersect(Model.DriverWaysId);
            if(!list.Any())
            {
                @Html.ActionLink("Publier un trajet", "CarPoolingForm", "Way", new {@event = Model.Event.Id}, new {@class = "linkAction"})
            }
            else
            {
                <span>Vous avez déjà créé un trajet sur cet évènement. </span>
            }
        }
        else
        {
            <span>Pour publier un trajet vous devez obligatoire renseigner au moin un vehicule dans votre profil. </span>
        }
        
    </div>
}

<div class="list-ways">
    <h3>Liste des trajets associés</h3>
    @foreach(var item in Model.Ways)
    {
        <div class="item-waysevent">
            <div class="field">
                <label>Evenement</label>
                <span>@item.Event.Title - @item.Event.DateBegin.ToStringFr() (@item.Event.City)</span>
            </div>
            <div class="field">
                <label>Vehicule</label>
                <span>@item.Vehicule.BrandAndModelToString</span>
            </div>
            <div class="field">
                <label>Rendez-vous</label>
                <span>@item.MeetingPlace - @item.MeetingHour</span>
            </div>
            <div class="field">
                <label>Participation</label>
                <span>@item.Contribution</span>
            </div>
            <div class="field">
                <label>Places disponibles</label>
                <span>@item.NumberPlaces</span>
            </div>
            <div class="field">
                @Html.ActionLink("Devenir passager", "BecomePassagerForm", "Way", new {@wayId = item.Id}, new {@class = "linkAction"})
            </div>
        </div>
    }
</div>

<p>
    @Html.ActionLink("Retour à la liste", "Index")
</p>
